'use strict';
(function() {
	
	ngApp.service("masettingService", ['$http', 'AppConfigConstant', "Dialog", function($http, AppConfigConstant, Dialog) {
		var basePath = AppConfigConstant.BASE_PATH;
		return {
			start : function(ip, port, monitor, callback){
				monitor = monitor == null ? "" : monitor;
				$http.post(basePath + "malog/setting/start", {"ip" : ip, "port" : port, "monitor" : monitor}).success(function(data, status, headers, config){
					if(data.state == -1){
						Dialog.show(data.msg);
					}else {
						callback(data);
					}
				}).error(function(data, status, headers, config){
					Dialog.show(data);
				});
			},
			
			stop : function(ip, port, monitor, callback){
				monitor = monitor == null ? "" : monitor;
				$http.post(basePath + "malog/setting/stop", {"ip" : ip, "port" : port, "monitor" : monitor}).success(function(data, status, headers, config){
					if(data.state == -1){
						Dialog.show(data.msg);
					}else {
						callback(data);
					}
				}).error(function(data, status, headers, config){
					Dialog.show(data);
				});
			}
		};

	}]);

})();
